package keter.dao.org.impl;

import java.util.List;

import keter.dao.base.KeterAbstractDao;
import keter.dao.org.UnitDao;
import keter.domain.Unit;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

@Repository
public class UnitDaoImpl extends KeterAbstractDao<Unit> implements UnitDao {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(UnitDaoImpl.class);

    @Override
    public List<Unit> findByParentId(Long id) {
      return getResultList("from Unit u where u.parentId = :id", 
              wrap("id"),
              wrap(id)
      );
    }

    @Override
    public Unit findByCode(String code) {
        return getSingleResult("from Unit u where u.code = :code", 
                wrap("code"),
                wrap(code)
        );
    }

}
